package com.hsgene.user.persistence;

import com.hsgene.user.condition.DepartmentCondition;
import com.hsgene.user.domain.Department;
import com.hsgene.user.dto.orginazation.DepartmentDto;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @description:
 * @projectName: hdas-geneshop-server
 * @package: com.hsgene.order.persistence
 * @author: maodi
 * @createDate: 2018/11/5 10:06
 * @version: 1.0
 * Copyright: Copyright (c) 2018
 */
@Repository
public interface DepartmentRepository {

    /**
     * @param condition 部门条件
     * @return int
     * @description 部门条件查询数量
     * @author maodi
     * @createDate 2018/11/6 16:42
     */
    int queryDepartmentCountByCondition(DepartmentCondition condition);

    /**
     * @param condition 部门条件
     * @return List<DepartmentDto>
     * @description 部门条件查询
     * @author maodi
     * @createDate 2018/11/6 16:42
     */
    List<DepartmentDto> queryDepartmentByCondition(DepartmentCondition condition);

    /**
     * @param id 部门id
     * @return java.util.List<com.hsgene.user.dto.orginazation.DepartmentDto>
     * @description 部门根据id查询
     * @author maodi
     * @createDate 2018/11/6 16:44
     */
    List<DepartmentDto> queryDepartmentById(@Param("id") String id);

    /**
     * @param departmentName 部门
     * @param companyId      公司id
     * @return int
     * @description 部门名字，公司id查询数量
     * @author maodi
     * @createDate 2018/11/6 18:04
     */
    int queryDepartmentCountByName(@Param("departmentName") String departmentName, @Param("companyId") String
            companyId);

    /**
     * @param departmentName 部门名称
     * @param companyId      公司id
     * @param departmentId   部门id
     * @return int
     * @description 部门名字，公司id除本身外查询数量
     * @author maodi
     * @createDate 2018/11/7 15:07
     */
    int queryDepartmentCountByNameExcludeSelf(@Param("departmentName") String departmentName, @Param("companyId") String
            companyId, @Param("departmentId") String departmentId);

    /**
     * @param companyId 公司id
     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @description 部门名字下拉框数据源/根据公司id查询部门名字下拉框数据源
     * @author maodi
     * @createDate 2018/11/7 9:14
     */
    List<Map<String, Object>> selectDepartment(@Param("companyId") String companyId);

    /**
     * @param departmentId 部门id
     * @param companyId    公司id
     * @return int
     * @description 根据部门id和公司id查询数量
     * @author maodi
     * @createDate 2018/11/7 18:26
     */
    int queryCountByDepartmentIdAndCompanyId(@Param("departmentId") String departmentId, @Param("companyId") String
            companyId);

    /**
     * @param companyId 公司id
     * @return int
     * @description 查询公司id在部门中使用数量
     * @author maodi
     * @createDate 2018/11/7 18:41
     */
    int queryCountByCompanyId(@Param("companyId") String companyId);

    /**
     * @param department 部门
     * @return void
     * @description 部门新增
     * @author maodi
     * @createDate 2018/11/6 16:44
     */
    int insertDepartment(Department department);

    /**
     * @param department 部门
     * @return void
     * @description 部门修改
     * @author maodi
     * @createDate 2018/11/6 16:45
     */
    int updateDepartment(Department department);

    /**
     * @param department 部门
     * @return void
     * @description 部门删除
     * @author maodi
     * @createDate 2018/11/6 16:45
     */
    int deleteDepartment(Department department);

    /**
     * @param departmentIds  部门id数组
     * @param updateDateTime 更新时间
     * @return int
     * @description 部门批量删除
     * @author maodi
     * @createDate 2018/11/13 17:04
     */
    int deleteDepartmentMulti(@Param("departmentIds") String[] departmentIds, @Param("updateDateTime") Date
            updateDateTime);

    /**
     * @param departmentId 部门id
     * @return java.lang.Integer
     * @description 查询部门id在系统用户表中使用数量
     * @author maodi
     * @createDate 2018/11/29 11:34
     */
    Integer queryOperationAccountCountByDepartmentId(@Param("departmentId") String departmentId);

    /**
     * @param companyId    公司id
     * @param departmentId 部门id
     * @return void
     * @description 更新该部门下职位对应的公司
     * @author maodi
     * @createDate 2018/12/14 16:55
     */
    void updatePositionCompany(@Param("companyId") String companyId, @Param("departmentId") String departmentId);
    /**
     *根据部门名称和公司id查部门
     * @author FX
     * @date 2019/1/7 11:34
     * @param departmentName
     * @param id
     * @return
     */
    Department queryByName(@Param("departmentName") String departmentName, @Param("companyId") String companyId);
}
